<?php
class Controller{
	private $var =array();
	/**
	 * 成功提示方法
	 */
	protected function success($msg,$url){
		header('Content-type:text/html;charset=utf-8');
		$str = <<<str
<script type="text/javascript">
alert("{$msg}");
location.href="{$url}";
</script>
str;
		echo $str;die;
	}
	
	/**
	 * 错误提示方法
	 */
	protected function error($msg){
		header('Content-type:text/html;charset=utf-8');
		$str = <<<str
<script type="text/javascript">
alert("{$msg}");
history.back();
</script>
str;
		echo $str;die;
	}
	/*
	 * 显示模板
	 */
	protected function display(){
//		$path = APP_VIEW_PATH .'/' . CONTROLLER . '/' .ACTION .'.html'; //组合模板文件路径
		$path = APP_VIEW_PATH . '/' . APP_NAME . '/' . CONTROLLER .'_'. ACTION . '.html';
		if(is_file($path)){
			extract($this->var); //extract — 从数组中将变量导入到当前的符号表
			include $path;
		}else{
			halt($path . '模板未找到！');
		}
	}
	/*
	 * 分配变量
	 */
	protected function assign($var,$value){
		$this->var[$var] = $value;
	}
}
?>